package com.ewili.x.special.service.data.impl;

import com.ewili.framework.utils.ObjectHttpClientUtils;
import com.ewili.x.special.service.data.inter.BlockTradingMarketService;
import com.ewili.x.special.task.thread.inter.BlockTradingMarketThreadTask;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class BlockTradingMarketServiceImpl implements BlockTradingMarketService {

    @Autowired
    BlockTradingMarketThreadTask blockTradingMarketThreadTask;

    @Override
    public void spideBlockTradingMarket() {
        String url = "http://dcfm.eastmoney.com/em_mutisvcexpandinterface/api/js/get?type=DZJYSCTJ&token=70f12f2f4f091e459a279469fe49eca5&cmd=&st=TDATE&sr=-1&p=4&ps=50&js=var%20lTMxalzw={pages:(tp),data:(x)}&rt=52482734";
        Long pages = ObjectHttpClientUtils.getEastMoneyJsonPages(url);
        if (pages == null || pages == 0) {
            return;
        }
        for (int i = 1; i <= pages; i++) {
            String doUrl = "http://dcfm.eastmoney.com/em_mutisvcexpandinterface/api/js/get?type=DZJYSCTJ&token=70f12f2f4f091e459a279469fe49eca5&cmd=&st=TDATE&sr=-1&p=" + i + "&ps=100&js=var%20lTMxalzw={pages:(tp),data:(x)}&rt=52482734";
            blockTradingMarketThreadTask.blockTradingMarket(doUrl);
        }
    }
}
